﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace LED_Utils.MultitrackControl
{
    public class GdiHelper
    {
        public static void SetDoubleBuffer(Control ctrl, bool value)
        {
            //Argument.VerifyNotNull("ctrl", ctrl);

            ControlStyles ctrlStyles = ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque ;

            Type ctrlType = ctrl.GetType();
            MethodInfo methodInfo = ctrlType.GetMethod("SetStyle", BindingFlags.NonPublic | BindingFlags.Instance);
            methodInfo.Invoke(ctrl, new object[] { ctrlStyles, value });
        }
    }
}
